#!/user/bin/env node

const Router = require('koa-router'),
	collection = require('../models/collection_mod.js'),
	router = new Router;
router.prefix('/api/collection');

router.post('/', async (ctx, next) => {
	let { user_id } = ctx.request.body;
	console.log(user_id);
	let res = await collection.Getlist(user_id);
	console.log(user_id);
	ctx.body = res;
})
router.put('/', async (ctx, next) => {
	let { user_id, commodity_id } = ctx.request.body;
	let res = await collection.Insert_coll(user_id, commodity_id);
	ctx.body = res;
})

router.delete('/', async (ctx, next) => {
	let { user_id, commodity_id } = ctx.request.body;
	let res = await collection.Delete_coll(user_id, commodity_id);
	ctx.body = res;
})
module.exports = router;
